.class public Llt/noframe/gpsfarmguide/utils/Calculations;
.super Ljava/lang/Object;
.source "Calculations.java"


# static fields
.field public static instance:Llt/noframe/gpsfarmguide/utils/Calculations;


# instance fields
.field private areaLimit:D

.field private areaLimit_origin:D

.field private areaUnit:Ljava/lang/String;

.field private areaUnitView:Landroid/widget/TextView;

.field private areaValue:Landroid/widget/TextView;

.field private distanceUnit:Ljava/lang/String;

.field private distanceUnitView:Landroid/widget/TextView;

.field private distanceValue:Landroid/widget/TextView;

.field private perimeterUnitView:Landroid/widget/TextView;

.field private perimeterValue:Landroid/widget/TextView;


# direct methods
.method public constructor <init>()V
    .locals 0

    .line 11
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static declared-synchronized getInstance()Llt/noframe/gpsfarmguide/utils/Calculations;
    .locals 2

    const-class v0, Llt/noframe/gpsfarmguide/utils/Calculations;

    monitor-enter v0

    .line 32
    :try_start_0
    sget-object v1, Llt/noframe/gpsfarmguide/utils/Calculations;->instance:Llt/noframe/gpsfarmguide/utils/Calculations;

    if-nez v1, :cond_0

    .line 33
    new-instance v1, Llt/noframe/gpsfarmguide/utils/Calculations;

    invoke-direct {v1}, Llt/noframe/gpsfarmguide/utils/Calculations;-><init>()V

    sput-object v1, Llt/noframe/gpsfarmguide/utils/Calculations;->instance:Llt/noframe/gpsfarmguide/utils/Calculations;

    .line 35
    :cond_0
    sget-object v1, Llt/noframe/gpsfarmguide/utils/Calculations;->instance:Llt/noframe/gpsfarmguide/utils/Calculations;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    monitor-exit v0

    return-object v1

    :catchall_0
    move-exception v1

    monitor-exit v0

    throw v1
.end method


# virtual methods
.method public doAreaCalculations()V
    .locals 3

    .line 81
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v0

    if-eqz v0, :cond_0

    .line 82
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v0

    invoke-static {v0}, Llt/noframe/gpsfarmguide/utils/Mathematics;->calculatePerimeter(Ljava/util/List;)D

    move-result-wide v0

    iget-object v2, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->distanceUnit:Ljava/lang/String;

    invoke-static {v0, v1, v2}, Llt/noframe/gpsfarmguide/utils/Mathematics;->convertDistance(DLjava/lang/String;)D

    move-result-wide v0

    invoke-virtual {p0, v0, v1}, Llt/noframe/gpsfarmguide/utils/Calculations;->setPerimeterValue(D)V

    .line 83
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v0

    invoke-static {v0}, Llt/noframe/gpsfarmguide/utils/Mathematics;->calculateArea(Ljava/util/List;)D

    move-result-wide v0

    iget-object v2, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaUnit:Ljava/lang/String;

    invoke-static {v0, v1, v2}, Llt/noframe/gpsfarmguide/utils/Mathematics;->convertArea(DLjava/lang/String;)D

    move-result-wide v0

    invoke-virtual {p0, v0, v1}, Llt/noframe/gpsfarmguide/utils/Calculations;->setAreaValue(D)V

    :cond_0
    return-void
.end method

.method public doDistanceCalculations()V
    .locals 3

    .line 76
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v0

    if-eqz v0, :cond_0

    .line 77
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getCurrent_measuring()Llt/noframe/gpsfarmguide/models/MeasuringModel;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/models/AbstractMeasuringModel;->getPoints()Ljava/util/List;

    move-result-object v0

    invoke-static {v0}, Llt/noframe/gpsfarmguide/utils/Mathematics;->calculateDistance(Ljava/util/List;)D

    move-result-wide v0

    iget-object v2, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->distanceUnit:Ljava/lang/String;

    invoke-static {v0, v1, v2}, Llt/noframe/gpsfarmguide/utils/Mathematics;->convertDistance(DLjava/lang/String;)D

    move-result-wide v0

    invoke-virtual {p0, v0, v1}, Llt/noframe/gpsfarmguide/utils/Calculations;->setDistanceValue(D)V

    :cond_0
    return-void
.end method

.method public iniArea(Landroid/content/Context;D)V
    .locals 0

    .line 45
    iput-wide p2, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaLimit_origin:D

    .line 46
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object p2

    invoke-virtual {p2}, Llt/noframe/gpsfarmguide/Data;->getMainFrame()Landroid/widget/FrameLayout;

    move-result-object p2

    const p3, 0x7f0901b9

    invoke-virtual {p2, p3}, Landroid/widget/FrameLayout;->findViewById(I)Landroid/view/View;

    move-result-object p2

    check-cast p2, Landroid/widget/TextView;

    iput-object p2, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->perimeterValue:Landroid/widget/TextView;

    .line 47
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object p2

    invoke-virtual {p2}, Llt/noframe/gpsfarmguide/Data;->getMainFrame()Landroid/widget/FrameLayout;

    move-result-object p2

    const p3, 0x7f0901ba

    invoke-virtual {p2, p3}, Landroid/widget/FrameLayout;->findViewById(I)Landroid/view/View;

    move-result-object p2

    check-cast p2, Landroid/widget/TextView;

    iput-object p2, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->perimeterUnitView:Landroid/widget/TextView;

    .line 48
    invoke-static {p1}, Llt/noframe/gpsfarmguide/utils/Preferences;->getDistanceUnit(Landroid/content/Context;)Ljava/lang/String;

    move-result-object p2

    invoke-virtual {p0, p2}, Llt/noframe/gpsfarmguide/utils/Calculations;->setPerimeterUnit(Ljava/lang/String;)V

    .line 50
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object p2

    invoke-virtual {p2}, Llt/noframe/gpsfarmguide/Data;->getMainFrame()Landroid/widget/FrameLayout;

    move-result-object p2

    const p3, 0x7f090058

    invoke-virtual {p2, p3}, Landroid/widget/FrameLayout;->findViewById(I)Landroid/view/View;

    move-result-object p2

    check-cast p2, Landroid/widget/TextView;

    iput-object p2, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaValue:Landroid/widget/TextView;

    .line 51
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object p2

    invoke-virtual {p2}, Llt/noframe/gpsfarmguide/Data;->getMainFrame()Landroid/widget/FrameLayout;

    move-result-object p2

    const p3, 0x7f09005a

    invoke-virtual {p2, p3}, Landroid/widget/FrameLayout;->findViewById(I)Landroid/view/View;

    move-result-object p2

    check-cast p2, Landroid/widget/TextView;

    iput-object p2, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaUnitView:Landroid/widget/TextView;

    .line 52
    invoke-static {p1}, Llt/noframe/gpsfarmguide/utils/Preferences;->getAreaUnit(Landroid/content/Context;)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {p0, p1}, Llt/noframe/gpsfarmguide/utils/Calculations;->setAreaUnit(Ljava/lang/String;)V

    .line 53
    iget-wide p1, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaLimit_origin:D

    iget-object p3, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaUnit:Ljava/lang/String;

    invoke-static {p1, p2, p3}, Llt/noframe/gpsfarmguide/utils/Mathematics;->convertArea(DLjava/lang/String;)D

    move-result-wide p1

    iput-wide p1, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaLimit:D

    return-void
.end method

.method public iniDistance(Landroid/content/Context;)V
    .locals 2

    .line 39
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getMainFrame()Landroid/widget/FrameLayout;

    move-result-object v0

    const v1, 0x7f0900e2

    invoke-virtual {v0, v1}, Landroid/widget/FrameLayout;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/TextView;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->distanceValue:Landroid/widget/TextView;

    .line 40
    invoke-static {}, Llt/noframe/gpsfarmguide/Data;->getInstance()Llt/noframe/gpsfarmguide/Data;

    move-result-object v0

    invoke-virtual {v0}, Llt/noframe/gpsfarmguide/Data;->getMainFrame()Landroid/widget/FrameLayout;

    move-result-object v0

    const v1, 0x7f0900e3

    invoke-virtual {v0, v1}, Landroid/widget/FrameLayout;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/TextView;

    iput-object v0, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->distanceUnitView:Landroid/widget/TextView;

    .line 41
    invoke-static {p1}, Llt/noframe/gpsfarmguide/utils/Preferences;->getDistanceUnit(Landroid/content/Context;)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {p0, p1}, Llt/noframe/gpsfarmguide/utils/Calculations;->setDistanceUnit(Ljava/lang/String;)V

    return-void
.end method

.method public setAreaUnit(Ljava/lang/String;)V
    .locals 1

    .line 149
    iget-object v0, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaUnitView:Landroid/widget/TextView;

    invoke-virtual {v0, p1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 150
    iput-object p1, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaUnit:Ljava/lang/String;

    return-void
.end method

.method public setAreaValue(D)V
    .locals 3

    .line 134
    iget-object v0, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaValue:Landroid/widget/TextView;

    invoke-static {p1, p2}, Llt/noframe/gpsfarmguide/utils/Utils;->smartRounding(D)D

    move-result-wide v1

    invoke-static {v1, v2}, Ljava/lang/String;->valueOf(D)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 135
    iget-wide v0, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaLimit:D

    cmpg-double v2, v0, p1

    if-gez v2, :cond_0

    .line 136
    iget-object p1, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaValue:Landroid/widget/TextView;

    invoke-virtual {p1}, Landroid/widget/TextView;->getResources()Landroid/content/res/Resources;

    move-result-object p2

    const v0, 0x7f060127

    invoke-virtual {p2, v0}, Landroid/content/res/Resources;->getColor(I)I

    move-result p2

    invoke-virtual {p1, p2}, Landroid/widget/TextView;->setTextColor(I)V

    .line 137
    iget-object p1, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaUnitView:Landroid/widget/TextView;

    invoke-virtual {p1}, Landroid/widget/TextView;->getResources()Landroid/content/res/Resources;

    move-result-object p2

    invoke-virtual {p2, v0}, Landroid/content/res/Resources;->getColor(I)I

    move-result p2

    invoke-virtual {p1, p2}, Landroid/widget/TextView;->setTextColor(I)V

    goto :goto_0

    .line 139
    :cond_0
    iget-object p1, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaValue:Landroid/widget/TextView;

    invoke-virtual {p1}, Landroid/widget/TextView;->getResources()Landroid/content/res/Resources;

    move-result-object p2

    const v0, 0x106000b

    invoke-virtual {p2, v0}, Landroid/content/res/Resources;->getColor(I)I

    move-result p2

    invoke-virtual {p1, p2}, Landroid/widget/TextView;->setTextColor(I)V

    .line 140
    iget-object p1, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->areaUnitView:Landroid/widget/TextView;

    invoke-virtual {p1}, Landroid/widget/TextView;->getResources()Landroid/content/res/Resources;

    move-result-object p2

    invoke-virtual {p2, v0}, Landroid/content/res/Resources;->getColor(I)I

    move-result p2

    invoke-virtual {p1, p2}, Landroid/widget/TextView;->setTextColor(I)V

    :goto_0
    return-void
.end method

.method public setDistanceUnit(Ljava/lang/String;)V
    .locals 1

    .line 106
    iget-object v0, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->distanceUnitView:Landroid/widget/TextView;

    invoke-virtual {v0, p1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 107
    iput-object p1, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->distanceUnit:Ljava/lang/String;

    return-void
.end method

.method public setDistanceValue(D)V
    .locals 1

    .line 98
    iget-object v0, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->distanceValue:Landroid/widget/TextView;

    invoke-static {p1, p2}, Llt/noframe/gpsfarmguide/utils/Utils;->smartRounding(D)D

    move-result-wide p1

    invoke-static {p1, p2}, Ljava/lang/String;->valueOf(D)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {v0, p1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    return-void
.end method

.method public setPerimeterUnit(Ljava/lang/String;)V
    .locals 1

    .line 124
    iget-object v0, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->perimeterUnitView:Landroid/widget/TextView;

    invoke-virtual {v0, p1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 125
    iput-object p1, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->distanceUnit:Ljava/lang/String;

    return-void
.end method

.method public setPerimeterValue(D)V
    .locals 1

    .line 116
    iget-object v0, p0, Llt/noframe/gpsfarmguide/utils/Calculations;->perimeterValue:Landroid/widget/TextView;

    invoke-static {p1, p2}, Llt/noframe/gpsfarmguide/utils/Utils;->smartRounding(D)D

    move-result-wide p1

    invoke-static {p1, p2}, Ljava/lang/String;->valueOf(D)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {v0, p1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    return-void
.end method
